package com.management.controller;


import com.management.controller.form.*;
import com.management.service.ProjectInfoService;
import com.management.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.xml.transform.Source;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙世超
 * @since 2022-03-23
 */
@Api(tags = "项目相关")
@RestController
@RequestMapping("/projectInfo")
public class ProjectInfoController {

    @Resource
    private ProjectInfoService projectInfoService;

    /**
     * 获取当前所有项目
     * @return
     */
    @ApiOperation("获取当前所有项目")
    @PostMapping("/getAllProjects")
    public Result getAllProject(@RequestBody ProjectPageForm projectPageForm){

      Result result=  projectInfoService.getAllProjects(projectPageForm);
      return result;
    }

    /**
     * 添加项目
     * @param addProjectForm 接收参数
     * @return
     */
    @ApiOperation("添加项目")
    @PostMapping("addProject")
    public Result addProject(@RequestBody AddProjectForm addProjectForm){
       Result result= projectInfoService.addProject(addProjectForm);
        return result;
    }

    /**
     * 模糊查询
     * @param
     * @return
     */
    @ApiOperation("模糊查询")
    @GetMapping("getProjectByName")
    public Result getProjectByName(GetProjectByNameForm getProjectByNameForm){
       Result result= projectInfoService.findProjectByName(getProjectByNameForm);

       return result;
    }

    /**
     * 查询所有项目
     * @return
     */
    @ApiOperation("查询所有项目")
    @GetMapping("getAllProject")
    public Result getAllProject(){
       Result result= projectInfoService.findAllProject();
       return result;
    }

    /**
     * 关闭某个项目
     * @param projectId 项目ID
     *
     * @return
     */
    @ApiOperation("关闭某个项目")
    @GetMapping("closeProject")
    public Result closeProject(Integer projectId){
       Result result= projectInfoService.closeProject(projectId);
       return result;
    }

    /**
     * 修改项目信息
     * @param changeProjectForm 相关参数
     * @return
     */
    @ApiOperation("修改项目信息")
    @PostMapping("changeProject")
    public Result changeProject(@RequestBody ChangeProjectForm changeProjectForm){
       Result result= projectInfoService.changeProject(changeProjectForm);
    return result;
    }

    /**
     * 修改项目信息之前判断该项目是否已经关闭
     * @param projectId 项目ID
     * @return
     */
    @ApiOperation("修改项目信息之前判断该项目是否已经关闭")
    @GetMapping("checkProjectState")
    public Result checkProjectState(Integer projectId){
       Result result= projectInfoService.checkProjectState(projectId);
        return result;
    }

    /**
     * 查看我参与的项目详细缺陷信息
     * @param getMyProjectDescForm 参数
     * @return
     */
    @ApiOperation("查看我参与的项目详细缺陷信息")
    @PostMapping("getMyPeojectDesc")
    public Result getMyPeojectDesc(@RequestBody GetMyProjectDescForm getMyProjectDescForm){
       Result result= projectInfoService.getMyProjectDesc(getMyProjectDescForm);
        return result;
    }
}

